package com.ihr360.job.core.item.support;

import com.ihr360.job.core.item.ItemWriter;
import org.springframework.data.util.Pair;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MapPairWriter<K,T> implements ItemWriter<Pair> {

    private Map<K,T> writtenItems = new HashMap<>();

    @Override
    public void write(List<? extends Pair> pairs) throws Exception {
        for (Pair<K,? extends T> pair : pairs) {
            writtenItems.put(pair.getFirst(),pair.getSecond());
        }
    }

    public Map<K,? extends T> getWrittenItems()
    {
        return this.writtenItems;
    }
}
